package com.ibm.cps.spark.streaming.adapter;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.ibm.util.JSONUtility;
import com.ibm.util.exception.CPSException;

/**
 * Created by telekinesis on 4/30/15.
 */
public class TestJSONUtility {
    public static void main(String[] args) throws CPSException{
        String message = "{\"size\":5,\"step\":3,\"coefficient\":3,\"attributename\":\"tag2\",\"processorid\":\"553df41ce778ecc7dce45316\",\"parentprocessors\":[\"000000000b9bf990d0464068\"],\"tenantid\":\"123456789012345678901239\",\"type\":\"dft\"},{\"topicname\":\"stream_data\",\"type\":\"input\",\"schemaid\":\"0000000000d0a84c90f2f57b\",\"processorid\":\"000000000b9bf990d0464068\",\"tenantid\":\"123456789012345678901239\"},{\"type\":\"schema\",\"schemaid\":\"0000000000d0a84c90f2f57b\",\"schema\":[{\"name\":\"phase\",\"datatype\":\"int\"}],\"tenantid\":\"123456789012345678901239\"},{\"processorid\":\"00000000008966dcc7076992\",\"rulename\":\"naive rule\",\"rule\":\"phase>10\",\"parentprocessors\":[\"000000000b9bf990d0464068\"],\"type\":\"rule\",\"model\":true,\"topicname\":\"anomaly_event\",\"tenantid\":\"123456789012345678901239\"},{\"type\":\"rule\",\"parentprocessors\":[\"553df41ce778ecc7dce45316\"],\"topicname\":\"anomaly_event\",\"rulename\":\"rule3\",\"rule\": \"payload(0) >= 5 and payload(0) <20\",\"model\":\"true\"}";
        ObjectNode objectNode = (ObjectNode) JSONUtility
                .fromString(message);
        System.out.println(objectNode);
    }
}
